package com.sxfq.loansupermarket.backsystem.modular.theTest.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.modular.theTest.dao.AnswerListDao;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.AnswerListInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.SearchTestingInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.UserForTestInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.service.IAnswerListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class AnswerListServiceImpl implements IAnswerListService {

    @Autowired
    private AnswerListDao answerListDao;

    @Override
    public List<AnswerListInfo> selectPageAnswerListByQueryGetMap(Page<AnswerListInfo> page, SearchTestingInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        params.put("userForTestId", searchInfo.getUserForTestId());
        return answerListDao.getQueryAnswerListPage(page, params);
    }

    @Transactional
    public void UpdateWithTheInfo(UserForTestInfo userForTestInfo) throws Exception {
        answerListDao.updateById(userForTestInfo);
    }

}
